//
//  ColorConverter.swift
//  DKE-Album
//
//  Created by dagny on 2025/9/26.
//  Copyright © 2025 杨东宝. All rights reserved.
//

import Foundation
class ColorConverter {
    
    /// 将 UIColor 转换为 ARGB 整数
    static func toABGR(_ color: UIColor) -> UInt32? {
        guard let components = color.argbComponents else { return nil }

        let a = components.alpha << 24
        let b = components.blue  << 16
        let g = components.green << 8
        let r = components.red
        
        return a | b | g | r
    }
    /// 提取 ARGB 各个分量 (0-255 范围)
    static func extractARGBComponents(_ color: UIColor) -> (alpha: Int, red: Int, green: Int, blue: Int)? {
        guard let components = color.argbComponents else { return nil }
        
        return (
            alpha: Int(components.alpha * 255),
            red: Int(components.red * 255),
            green: Int(components.green * 255),
            blue: Int(components.blue * 255)
        )
    }
}
